#include <stdio.h>
int main() {
    int m = 0, n = 0;
    char a[101][101];
    int b[102][102] = {0};
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {   
            scanf("%c", &a[i][j]);
            if(a[i][j] != '*' && a[i][j] != '?')
            {
                scanf("%c", &a[i][j]);
            }
            if (a[i][j] == '*') {
                for (int x = -1; x <= 1; x++)
                {
                    for (int y = -1; y <= 1; y++)
                    {
                        if (x != 0 || y != 0)
                        {
                            b[i + x][j + y]++;
                        }
                    }
                }
            }
        }
    }
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            if (a[i][j] == '*')
                printf("%c", a[i][j]);
            else
                printf("%d", b[i][j]);
        }
        printf("\n");
    }
    return 0;
}